﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Betop.Lib.Enums;



namespace Betop.Lib.Core.Right
{
    public class RecordRightBO
    {
        #region 成员变量
        private IRecordRightDAL right;
        #endregion

        #region 属性
        public TableName TableName
        {
            set
            {
                right.TableName = value.ToString();
            }
        }
        #endregion

        #region 构造函数
        public RecordRightBO(TableName tableName)
        {
            right = RightBase.CreateRecordRight(tableName.ToString());
        }

        public RecordRightBO(string tableName)
        {
            right = RightBase.CreateRecordRight(tableName);
        }
        #endregion

        #region 根据拥有者ID获得所有项
        /// <summary>
        /// 根据拥有者ID获得所有项
        /// </summary>
        /// <param name="iOwnerID"></param>
        /// <returns></returns>
        public List<int> GetBindIDs(int ownerID, RecordRightName rightName, RightOwnerType ownerType)
        {
            List<int> lstBindID = right.GetBindIDs(ownerID, (int)rightName, (int)ownerType);
            return lstBindID;
        }
        #endregion

        #region 获得权限所有者的ID集合
        /// <summary>
        /// 获得权限所有者的ID集合
        /// </summary>
        /// <param name="iBindID"></param>
        /// <returns></returns>
        public List<int> GetOwnerIDs(int bindID, RecordRightName rightName, RightOwnerType ownerType)
        {
            List<int> lstOwnerIDs = right.GetOwnerIDs(bindID, (int)rightName, (int)ownerType);
            return lstOwnerIDs;
        }
        #endregion

        #region 保存对权限的修改
        /// <summary>
        /// 保存对权限的修改
        /// </summary>
        /// <param name="lstBindIDs"></param>
        /// <param name="iOwnerID"></param>
        /// <returns></returns>
        public void SaveBindIDs(List<int> lstBindIDs, int iOwnerID, RecordRightName rightName, RightOwnerType ownerType)
        {
            right.SaveBindIDs(lstBindIDs, iOwnerID, (int)rightName, (int)ownerType);
        }
        #endregion

        #region 保存拥有者ID
        /// <summary>
        /// 保存拥有者ID
        /// </summary>
        /// <param name="lstOwnerIDs"></param>
        /// <param name="iBindID"></param>
        /// <returns></returns>
        public void SaveOwnerIDs(List<int> lstOwnerIDs, int bindID, RecordRightName rightName, RightOwnerType ownerType)
        {
            right.SaveOwnerIDs(lstOwnerIDs, bindID, (int)rightName, (int)ownerType);

        }
        #endregion

        #region 判断是否拥有该权限
        /// <summary>
        /// 判断是否拥有该权限
        /// </summary>
        /// <param name="strBindID"></param>
        /// <param name="strOwnerID"></param>
        /// <returns></returns>
        public bool HaveRight(int iBindID, int iOwnerID, RecordRightName rightName, RightOwnerType ownerType)
        {
            bool blnFlag = right.HaveRight(iBindID, iOwnerID, (int)rightName, (int)ownerType);
            return blnFlag;
        }
        #endregion
    }
}
